package com.zjdiepu.www.rest.api.dz;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.common.consts.SystemConsts;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.commpent.handler.TokenUserHelper;
import com.zjdiepu.www.ibiz.dz.IDzSignLoanAmountService;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.dz.dto.DzSignLoanAmount;

@RestController
@RequestMapping(value= "DzSignLoanAmountAppController", produces="application/json;charset=UTF-8")
@Api(tags = {"贷款中的签约贷款额"}, produces="application/json;charset=UTF-8")
public class DzSignLoanAmountAppController extends BaseController{

	@Resource
	private IDzSignLoanAmountService dzSignLoanAmountService;
	
	@Resource
    private TokenUserHelper tokenUserHelper;
	
	 @ApiOperation(value = "贷款中的签约贷款额",response = Integer.class, httpMethod="POST")
	    @ApiImplicitParams({
	    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
	    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
	    })
	    @RequestMapping(value = "countLessLoaningSignLoanAmount", method = RequestMethod.POST)
	public ApiResponse countLessLoaningSignLoanAmount(){
		 SysUser currentUser = tokenUserHelper.getUser();
		 DzSignLoanAmount dzSignLoanAmount= new DzSignLoanAmount();
		 dzSignLoanAmount.setSalersmanId(currentUser.getSalersmanId());
		 dzSignLoanAmount.setBusiStatusNqMore(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());
		 dzSignLoanAmount.setDpStatus(1);
		 Double count=dzSignLoanAmountService.countLoaningSignLoanAmount(dzSignLoanAmount);
		 Map<String,Object> response=CollectionInitUtil.emptyMap();
		 if(count==null){
			response.put("count", 0); 
			return ApiResponse.success(response);
		 }
		response.put("count", count);
		return ApiResponse.success(response);
	}
	 
	 @ApiOperation(value = "已完成的签约贷款额",response = Integer.class, httpMethod="POST")
	    @ApiImplicitParams({
	    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
	    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
	    })
	    @RequestMapping(value = "countEqualLoaningSignLoanAmount", method = RequestMethod.POST)
	public ApiResponse countEqualLoaningSignLoanAmount(){
		 SysUser currentUser = tokenUserHelper.getUser();
		 DzSignLoanAmount dzSignLoanAmount= new DzSignLoanAmount();
		 dzSignLoanAmount.setSalersmanId(currentUser.getSalersmanId());
		 dzSignLoanAmount.setBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());
		Double count=dzSignLoanAmountService.countLoaningSignLoanAmount(dzSignLoanAmount);
		Map<String,Object> response=CollectionInitUtil.emptyMap();
		if(count==null){
			response.put("count", 0); 
			return ApiResponse.success(response);
		 }
		response.put("count", count);
		return ApiResponse.success(response);
	}
}
